"""LangGraph single-node graph template.

Returns a predefined response. Replace logic and configuration as needed.
"""

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Dict, TypedDict

from langchain_core.runnables import RunnableConfig
from langgraph.graph import StateGraph

from langgraph.graph import MessagesState
from langchain_core.messages import AIMessage

class Configuration(TypedDict):
    """Configurable parameters for the agent.

    Set these when creating assistants OR when invoking the graph.
    See: https://langchain-ai.github.io/langgraph/cloud/how-tos/configuration_cloud/
    """
    my_configurable_param: str


@dataclass
class State:
    """Input state for the agent.

    Defines the initial structure of incoming data.
    See: https://langchain-ai.github.io/langgraph/concepts/low_level/#state
    """
    changeme: str = "example"


async def call_model(state: State, config: RunnableConfig) -> Dict[str, Any]:
    """Process input and returns output.

    Can use runtime configuration to alter behavior.
    """
    configuration = config["configurable"]
    # return {
    #     "changeme": "output from call_model. "
    #     f'Configured with {configuration.get("my_configurable_param")} for hhwang'
    # }
    return {"messages": [AIMessage(f"Available tables 4 for hhwang")]}

async def call_model1(state: MessagesState) -> Dict[str, Any]:
    """Process input and returns output.

    Can use runtime configuration to alter behavior.
    """
    # return {"messages": [
    #             {"role": "human","content": "What is LangGraph?"},
    #             AIMessage(f"Available tables 4 for hhwang")
    #             ]
    #         }
    return {"messages": [AIMessage(f"Available tables 3 for hhwang")]}


# Define the graph
graph = (
    # StateGraph(State, config_schema=Configuration)
    # .add_node(call_model)
    # .add_edge("__start__", "call_model")

    StateGraph(MessagesState)
    .add_node(call_model1)
    .add_edge("__start__", "call_model1")
    .compile(name="graph1")
)
